import React from 'react'
import { withRouter, Switch, Redirect } from 'react-router-dom'
import LoadableComponent from '../../utils/LoadableComponent'
import PrivateRoute from '../PrivateRoute'
//首页
const Home = LoadableComponent(()=>import('../../routes/Home/index')) 
//用户管理
const User = LoadableComponent(()=>import('../../routes/User/index')) 
//帖子管理
const Post = LoadableComponent(()=>import('../../routes/Post/index')) 
//链接管理
const Link = LoadableComponent(()=>import('../../routes/Link/index')) 
//消息管理
const Message = LoadableComponent(()=>import('../../routes/Message/index')) 
//管理员设置
const Administrator = LoadableComponent(()=>import('../../routes/Administrator/index')) 

@withRouter
class ContentMain extends React.Component {
  render () {
    return (
      <div style={{padding: 16, position: 'relative'}}>
        <Switch>
          <PrivateRoute exact path='/home' component={Home}/>

          <PrivateRoute exact path='/home/user' component={User}/>

          <PrivateRoute exact path='/home/post' component={Post}/>

          <PrivateRoute exact path='/home/link' component={Link}/>

          <PrivateRoute exact path='/home/message' component={Message}/>

          <PrivateRoute exact path='/home/administrator' component={Administrator}/>

          <Redirect exact from='/' to='/home'/>
        </Switch>
      </div>
    )
  }
}

export default ContentMain